<h1> Now viewing: <%= @event.name %> </h1>

<form>
  <h3>Event Information</h3>
  <div class="show_container">
    <p>
      <label>Name</label><br />
      <span class="show_info"><%= @event.name %></span>
    </p>
    <p>
      <label>Starts at</label> <br />
      <span class="show_info"><%= @event.starts_at.strftime("%b %d, %y - %I:%M%p") %></span>
    </p>
    <p>
      <label>Ends at</label> <br />
      <span class="show_info"><%= @event.ends_at.strftime("%b %d, %y - %I:%M%p") %></span>
    </p>
  </div>
  <br />
  <h3>Personnel Requirements</h3>
  <div class="show_container">
    <p>
      <span class="show_info"><%= @event.volunteers_req %></span>
      <%= image_tag("/images/icons/roles/16-volunteer.png", :class => "icon", :title => "Volunteer(s) Required") %><label>Volunteer(s) Required</label>
    </p>
    <p>
      <span class="show_info"><%= @event.volunteers_req %></span>
      <%= image_tag("/images/icons/roles/16-keyholder.png", :class => "icon", :title => "Keyholder(s) Required") %><label>Keyholder(s) Required</label>
    </p>
    <p>
      <span class="show_info"><%= @event.boardmembers_req %></span>
      <%= image_tag("/images/icons/roles/16-boardmember.png", :class => "icon", :title => "Boardmember(s) Required") %><label>Boardmember(s) Required</label>
    </p>
    <p>
      <% if @event.has_required_volunteers && @event.has_required_boardmembers && @event.has_required_keyholders %>
        <%= image_tag("/images/icons/png-8/16-em-check.png", :title => "People requirements met", :class => "icon", :style => "vertical-align: text-top") %> <label>Requirements satisfied</label>
      <% else %>
        <%= image_tag("/images/icons/png-8/16-message-warn.png", :title => "People requirements not met", :class => "icon", :style => "vertical-align: text-top") %> <label>Requirements not met</label>
      <% end %>
    </p>
  </div>
  <br />
  <h3>Current Volunteers</h3>
  <div class="show_container">
    <p>
      <% if @event.people.count > 0 %>
        <% @event.people.each do |person| %>
          <label> <%= person.name %> </label> <br />
        <% end %>
      <% else %>
        <label> None </label>
      <% end %>
    </p>
  </div>
  <br />
  <h3>Actions</h3>
  <div class="show_container">
    <p>
      <% if !current_user.person.is_a_volunteer_for(@event) %>
        <span id="action_volunteer_for_event" class="action"><%= image_tag("/images/icons/roles/16-volunteer.png", :class => "icon") %> <label>Volunteer for this event</label></span>
      <% else %>
        <span id="action_volunteer_for_event" class="action" style="opacity: 0.4"><%= image_tag("/images/icons/roles/16-volunteer.png", :class => "icon") %> <label>Volunteer for this event</label></span>
      <% end %>
      <% if current_user && current_user.person.is_keyholder? %>
        <span id="action_edit_event" class="action"><%= image_tag("/images/icons/png-8/16-tool-b.png", :class => "icon") %> <label>Edit this event</label></span>
      <% end %>
    </p>
  </div>
  <% if @event.completed %>
    <br />
    <h3>Event Stats</h3>
    <div class="show_container">
      <p>
        <span class="show_info"><%= @event.visitors.count %> Visitors Attended</span>
        <span class="show_info">
          :<% if @event.visitors.count > 0 %>
           <br />
            <% @event.visitors.each do |visitor| %>
               <br /> <%= visitor.name %>
            <% end %>
          <% end %>
        </span>
      </p>
    </div>
  <% end %>

</form>

<script type="text/javascript">
  jQuery(document).ready(function(){
    jQuery("#action_edit_event").click(function(){
      window.location = "<%= edit_event_path(@event.id) %>";
    });
    
    jQuery("#action_volunteer_for_event").click(function(){
<% if !current_user.person.is_a_volunteer_for(@event) %>
  window.location = "<%= volunteer_path(@event.id) %>";
<% else %>
  alert("You have already volunteered for this event");
<% end %>
});
    
})

</script>